A Functional Notation for Functional Dependencies

نویسندگان

  • Matthias Neubauer
  • Peter Thiemann
  • Martin Gasbichler
  • Michael Sperber
چکیده

Functional dependencies help resolve many of the ambiguities that result from the use of multi-parameter type classes. They effectively enable writing programs at the type-level which significantly enhances the expressive power of Haskell’s type system. Among the applications of this technique are the emulation of dependent types, and precise typechecking for XML and HTML combinator libraries. Unfortunately, the notation presently used for functional dependencies implies that the type-level programs are logic programs, but many of its applications are conceptually functional programs. We propose an alternative notation for functional dependencies which adds a functional-programming notation to Haskell’s type classes and makes applications of functional dependencies significantly more readable. We apply the new notation to our examples and study the problems arising due to Haskell’s open world assumption and overlapping instances. Since the invention of type classes more than a decade ago [12], every new year has seen astonishing new applications and interesting extensions of the original idea. The most recent addition is Jones’s incorporation of functional dependencies [8] which allow the formulation of tighter constraints on the instances 1 Email: [email protected] 2 Email: [email protected] 3 Email: [email protected] 4 Email: [email protected] 101 Gasbichler, Neubauer, Sperber, Thiemann of multi-parameter type classes. A functional dependency is a declaration which specifies that a set of parameters of a type class uniquely determines another parameter. Such a specification avoids many ambiguous typings. Functional dependencies constrain the instance declarations so that they specify a function at the type level. This functionality makes it feasible to write regular programs entirely evaluated by the type checker, opening the door for a wide range of potential applications [6,9]. Unfortunately, the use of functional dependencies is hampered by the traditional notation of type classes as relations and instances as logic programs computing these relations: As the resulting programs are getting more complex, they often become awkward and hard to read. This is not a fault of the mechanism of functional dependencies per se, but of the syntax offered by current implementations. Thus, in this paper, we suggest a notational shift for type classes: View a type class as a type-level function instead of a type-level relation. We offer some realistic example applications of functional dependencies which would benefit significantly from such a notation. Moreover, we give a brief formal outline of how the new notation may be implemented by a translation to the traditional syntax. We present the relevant part of a larger example—type-safe combinator libraries for XML documents—and discuss some of the problems remaining. 1 Simulating Dependent Types We start our investigation with two simple examples drawn from the realm of dependent types: formatted printing and specified list operations. 1.1 A type-safe sprintf The sprintf function from the C-library is an example of an unsafe function that can be made type-safe by using a dependent type [1]: The first parameter of sprintf is a format specifier which determines the number and type of the remaining parameters. The idea here is that a type-level function computes the type of the remaining parameters from the format specifier. For this to work in Haskell, format specifiers cannot simply be strings with control characters but rather String constants or values from the following datatypes: 5 data I f = I f data C f = C f data S f = S String f Using these datatypes, the format specifier S "Int: " (I (S ", Char: " (C "."))) 5 Danvy [5] has shown that this particular example can be made to work relying only on ML-style polymorphism.

برای دانلود رایگان متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

Extending DLR with Labelled Tuples, Projections, Functional Dependencies and Objectification

We introduce an extension of the n-ary description logic DLR to deal with attribute-labelled tuples (generalising the positional notation), with arbitrary projections of relations (inclusion dependencies), generic functional dependencies and with global and local objectification (reifying relations or their projections). We show how a simple syntactic condition on the appearance of projections ...

متن کامل

Use of UML for modeling non-functional aspects

This paper introduces a proposal for representing non-functional aspects by using UML. Our purpose is to apply UML-concepts in combination with OCL in order to describe the non-functional aspects of software systems by resorting to the NoFun notation formulated by [7]. On one hand, we make use of the UML concepts for defining stereotypes, class compartments and stereotyped dependencies to repre...

متن کامل

Brain Functional Correlates of Intelligence Score in ADHD Based on EEG

Introduction: It has been shown that intelligence as a general mental ability is related to the structure and function of the brain regions. However, the specificity of these regional dependencies to the intelligence scores in the typical and atypical developed individuals needs to be well understood. In this study, we hypothesized that neural correlates of IQ should not have a fixed pattern ra...

متن کامل

A Bayesian Networks Approach to Reliability Analysis of a Launch Vehicle Liquid Propellant Engine

This paper presents an extension of Bayesian networks (BN) applied to reliability analysis of an open gas generator cycle Liquid propellant engine (OGLE) of launch vehicles. There are several methods for system reliability analysis such as RBD, FTA, FMEA, Markov Chains, and etc. But for complex systems such as LV, they are not all efficiently applicable due to failure dependencies between compo...

متن کامل

Problem Decomposition Method to Compute an Optimal Cover for a Set of Functional Dependencies

The paper proposes a problem decomposition method for building optimal cover for a set of functional dependencies to decrease the solving time. At the beginning, the paper includes an overview of the covers of functional dependencies. There are considered definitions and properties of non redundant covers for sets of functional dependencies, reduced and canonical covers as well as equivalence c...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 2001